package jiazai;

public class Jiazai {

    public static void main(String[] args) {
//        System.out.println("---------------------第一组---------------------");
//        One one1 = new One();
//        one1.method();
//        one1.method2();
//        System.out.println("---------------------");
//        One one2 = new One();
//        one2.method();
//        one2.method2();
//        System.out.println("---------------------第一组---------------------");
//
//        System.out.println("---------------------第二组---------------------");
//        Two two = new Two();
//        two.method();
//        two.method2();
//        System.out.println("---------------------");
//        Two two2 = new Two();
//        two2.method();
//        two2.method2();
//        System.out.println("---------------------第二组---------------------");

        System.out.println("---------------------第三组---------------------");
        System.out.println(One.finalOne);
        System.out.println(One.staticOne);
        System.out.println("---------------------第三组---------------------");

//        System.out.println("---------------------第四组---------------------");
//        System.out.println(Two.finalOne);
//        System.out.println(Two.staticOne);
//        System.out.println("---------------------第四组---------------------");
//
//        System.out.println("---------------------第五组---------------------");
//        System.out.println(Two.finalTwo);
//        System.out.println(Two.staticTwo);
//        System.out.println("---------------------第五组---------------------");


    }
}

class One {
    public final static int finalOne = 10;
    public static int staticOne;

    static {
        //不论new多少对象 只会在第一次执行一次
        System.out.println("one static");
    }

    {
        //每次都会执行
        System.out.println("one weizhi ");
    }

    public One() {
        System.out.println("one init");
    }

    public void method() {
        System.out.println("one method");
    }

    public void method2() {
        System.out.println("one method2");
    }
}

class Two extends One {

    public final static int finalTwo = 10;
    public static int staticTwo = 20;

    static {
        System.out.println("two static");
    }

    {
        System.out.println("two weizhi");
    }

    public Two() {
        System.out.println("two init");
    }

    public void method() {
        System.out.println("two method");
    }

    public void method2() {
        System.out.println("two method2");
    }
}
